cmake_minimum_required(VERSION 3.20)

#xxxxxxxxxxxxxxxxxxx 添加Conan生成的 toolchain file
# set(CMAKE_TOOLCHAIN_FILE ${CMAKE_BINARY_DIR}/conan_toolchain.cmake)

#xxxxxxxxxxxxxxxxxxx 是否使用 thirdparty 中的库
# list(PREPEND CMAKE_PREFIX_PATH "${MY_THIRD_PARTY}")
if(TRUE AND MSVC)
    set(CMAKE_CUDA_COMPILER_WORKS ON CACHE INTERNAL "" FORCE)
    # set(CMAKE_CUDA_COMPILER "C:/MyProgram/cuda/bin/nvcc.exe")
    # set(CMAKE_CUDA_COMPILER_FORCED TRUE)
endif()

#xxxxxxxxxxxxxxxxxxxxxxxxx 标出 cuda 是必须的
project(cucon LANGUAGES CXX CUDA)
include(./00config.cmake)
#------------- 检查 cuda
# include(CheckLanguage)
# check_language(CUDA)
##
add_subdirectory(src/common)
add_subdirectory(src/dosestat)
##
add_subdirectory(src/dosestatcuda)
##
add_subdirectory(src/runall)

##0000000000000000000000000000000000000000000000000000000000000000 install, package
#xxxxxxxxxxxxxxxxxxxxxxxcxxx 打包系统库
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)   # Win10 以前必备; 安装 Windows 通用 CRT（UCRT）库
set(CMAKE_INSTALL_DEBUG_LIBRARIES FALSE) # Debug 版 runtime
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)  # 禁止自动 install, 可以手动定制
include(InstallRequiredSystemLibraries)
message(STATUS "[my] System runtime detected:")
if(FALSE)
foreach(f ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})
    message("    ${f}")
endforeach()
endif()

#xxxxxxxxxxxxxxxxxxxxxxxxxxx 3rd 库的 .dll/.so
#安装主程序
# install(TARGETS ${MYEXE} DESTINATION bin)
install(TARGETS ${MY_EXE}
    RUNTIME DESTINATION bin
)

install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/runtime/"
    DESTINATION bin
    USE_SOURCE_PERMISSIONS
    ## 单独组件名, 可以使用 cmake --install . --component conan_runtime 单独装
    # COMPONENT conan_runtime
)
#xxxxxxxxxxxxxxxxxxxxxxxxxxx 3rd lib header-only 库
install(DIRECTORY "${MY_THIRD_PARTY_HXX}/"
    DESTINATION include
    USE_SOURCE_PERMISSIONS
)

##xxxxxxxxxxxxxxxxxxxxxxxxxxx cpack 设置
set(CPACK_GENERATOR "ZIP")       # Windows 用 ZIP/NSIS, macOS 用 DragNDrop
set(CPACK_PACKAGE_NAME ${MY_EXE})
set(CPACK_PACKAGE_VERSION ${MY_EXE_VERSION})
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_SOURCE_DIR}/dist_package")
include(CPack)